package com.ys.web.pay.model.po;

import com.ys.utils.base.j2se.Convert;
import com.ys.utils.base.j2se.StringHandler;
import com.ys.utils.pay.PayConfig;
import com.ys.utils.spring.config.SystemError;
import com.ys.utils.spring.properties.Config;
import lombok.Data;

/**
 * 钱包开户bean
 */
@Data
public class RechargeCreate extends PayBase {
    public String currency = "CNY";
    public String amount;
    public String notifyUrl = PayConfig._notifyUrl + "/webox/recharge/send?orderSn=%s";
    public String remark;

    public void check() {
        if (amount.contains(".")) {
            SystemError.wrapBs("400", "充值金额不能有小数");
        }
        if (StringHandler.getLong(this.amount) <= 0) {
            SystemError.wrapBs("400", "参数异常");
        }

        long compareMoney = StringHandler.getLong(StringHandler.parseMoney(amount));
        long min = StringHandler.getLong(Config.pp.get("wallet.recharge.money.min"));
        if (compareMoney < min) {
            SystemError.wrapBs("400", "充值金额不能小于" + StringHandler.moneyDesc(min) + "元");
        }
        long max = StringHandler.getLong(Config.pp.get("wallet.recharge.money.max"));
        if (compareMoney > max) {
            SystemError.wrapBs("400", "充值金额不能大于" + StringHandler.moneyDesc(max) + "元");
        }

        this.amount = String.valueOf(StringHandler.yuanToFen(this.amount));
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
